#ifndef _UI_CALENDAR_H_
#define _UI_CALENDAR_H_

#include "ui_widget.h"
#include "ui_trsprite.h"
#include "ui_text.h"

typedef void(*CalendarDrawExtraFunc)(const math::Vec2&, const math::Vec2&, int);

namespace ui
{
class UICalendar : public UIWidget
{
public:
/// stuff that every self-respecting widget should have
						UICalendar(UIWidget* pParent,const std::string& Name = "");
	virtual				~UICalendar();
	virtual bool		Create(const std::string& Name, const math::Vec2& Pos = math::Vec2(0.5f, 0.5f), const math::Vec2& Size= math::Vec2(0.1f, 0.1f));
	virtual	bool		Load(LuaPlus::LuaObject& _LObj);
	/// update
	virtual	bool		Tick(float dt);
	/// display
	virtual bool		Render(bool Force = false);
	/// register with LUA Bind
	static	void		Register(LuaPlus::LuaState* _pScript);


	//calendar specific methods
	void				SetBounds(int FirstDay, int LastDay, bool SundayIsFirst = true);

	static const int	SCROLL_VALUE = 7;
	bool				CanScrollUp();
	bool				CanScrollDown();
	void				ScrollUp();
	void				ScrollDown();

	void				SetDrawExtraFunc(CalendarDrawExtraFunc FuncPtr);

	int					GetFirstShownDay();
	int					GetLastShownDay();

	virtual void		RefreshFonts();

protected:


	//helper methods
	void				GetCellCoords(int x, int y, math::Vec2& Position, math::Vec2& Size);


	//MEMBERS


	//calendar info

	bool				m_SundayIsFirst;

	int					m_WeeksCount;

	int					m_FirstDay;
	int					m_LastDay;

	int					m_CurOffset;

	static const int	WEEK_DAYS = 7;
	UIText				m_WeekDaysText[WEEK_DAYS];

	CalendarDrawExtraFunc m_DrawExtraFunc;

	//Sprites

	TrSprite			m_SpriteWeekDayCell;

	TrSprite			m_SpriteEvenMonthCell;
	TrSprite			m_SpriteOddMonthCell;

	TrSprite			m_SpriteCurDayHightlight;


};


}  //namespace ui

#endif // _UI_CALENDAR_H_